<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 
        <title>Welcome to Design Zone......</title>
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/ext-all.css" />
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/file-upload.css" />
        <link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
        <script type="text/javascript" src="../../scripts/ext/adapter/ext-base.js">
        </script>
        <script type="text/javascript" src="../../scripts/ext/ext-all.js">
        </script>
        <script type="text/javascript" src="../../scripts/menu/EditableItem.js">
        </script>
        <script type="text/javascript" src="../../scripts/menu/RangeMenu.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/GridFilters.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/Filter.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/StringFilter.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/ListFilter.js">
        </script>
        <script type="text/javascript" src="../../scripts/form/FileUploadField.js">
        </script>
        <script type="text/javascript" src="../../scripts/i18nMessage.js">
        </script>
        <script type="text/javascript" src="../../scripts/utils.js">
        </script>
        <script type="text/javascript" src="../../scripts/selectMeasureSpecification.js">
        </script>
        <script type="text/javascript">
            var piMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.productidentification');
			var msMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.measurespecification');
			var referenceMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.reference');
			var fcMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.francecustomer');
            var message = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=message');
            
            var ctYesnoXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtYesno');
            var ctStatureXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtStature');
			
			var idValue = getPrarmeterValue(window.location, 'id');
            var startPage = getPrarmeterValue(window.location, 'startPage');
			  
            var ctYesnoStore = new Ext.data.Store({
                reader: new Ext.data.XmlReader({
                    record: 'item',
                    id: 'code',
                    totalRecords: 'itemTotal'
                }, ['code', 'description']),
                data: ctYesnoXmlLoader.getXml()
            });
            
            var ctStatureStore = new Ext.data.Store({
                reader: new Ext.data.XmlReader({
                    record: 'item',
                    id: 'code',
                    totalRecords: 'itemTotal'
                }, ['code', 'description']),
                data: ctStatureXmlLoader.getXml()
            });
            
            var isSimilaryCombo = new Ext.form.ComboBox({
                fieldLabel: piMessage.get('ui.productidentification.issimilary'),
                id: 'isSimilary',
                name: 'isSimilary',
                allowBlank: false,
                blankText: message.get('message.edit.noblank'),
                editable: false,
                store: ctYesnoStore,
                valueField: 'code',
                displayField: 'description',
                triggerAction: 'all',
                emptyText: message.get('message.combo.pleaseselect'),
                selectOnFocus: true,
                mode: 'local'
            });
            
            var isNewfashionedCombo = new Ext.form.ComboBox({
                fieldLabel: piMessage.get('ui.productidentification.isnewfashioned'),
                id: 'isNewfashioned',
                name: 'isNewfashioned',
                allowBlank: false,
                blankText: message.get('message.edit.noblank'),
                editable: false,
                store: ctYesnoStore,
                valueField: 'code',
                displayField: 'description',
                triggerAction: 'all',
                emptyText: message.get('message.combo.pleaseselect'),
                selectOnFocus: true,
                mode: 'local'
            });
            
            var isDifficultyCombo = new Ext.form.ComboBox({
                fieldLabel: piMessage.get('ui.productidentification.isdifficulty'),
                id: 'isDifficulty',
                name: 'isDifficulty',
                allowBlank: false,
                blankText: message.get('message.edit.noblank'),
                editable: false,
                store: ctYesnoStore,
                valueField: 'code',
                displayField: 'description',
                triggerAction: 'all',
                emptyText: message.get('message.combo.pleaseselect'),
                selectOnFocus: true,
                mode: 'local'
            });
            
            var ctStatureCombo = new Ext.form.ComboBox({
                fieldLabel: msMessage.get('ui.measurespecification.stature'),
                id: 'ctStature',
                name: 'ctStature',
                allowBlank: false,
                blankText: message.get('message.edit.noblank'),
                editable: false,
                store: ctStatureStore,
                valueField: 'code',
                displayField: 'description',
                triggerAction: 'all',
                emptyText: message.get('message.combo.pleaseselect'),
                selectOnFocus: true,
                mode: 'local'
            });
            
            Ext.onReady(function(){
                Ext.QuickTips.init();
                Ext.form.Field.prototype.msgTarget = 'side';
                
                var piXMLReader = new Ext.data.XmlReader({
                    record: 'item'
                }, [{
                    name: 'id',
                    mapping: 'id'
                }, {
                    name: 'ctProductFamily',
                    mapping: 'ctProductFamily'
                }, {
                    name: 'ctMachineType',
                    mapping: 'ctMachineType'
                }, {
                    name: 'type',
                    mapping: 'type'
                }, {
                    name: 'orderNumber',
                    mapping: 'orderNumber'
                }, {
                    name: 'yarnNumber',
                    mapping: 'yarnNumber'
                }, {
                    name: 'ctDesignType',
                    mapping: 'ctDesignType'
                }, {
                    name: 'style',
                    mapping: 'style'
                }, {
                    name: 'customerLinkman',
                    mapping: 'customerLinkman'
                }, {
                    name: 'model',
                    mapping: 'model'
                }, {
                    name: 'ctSeasonNumber',
                    mapping: 'ctSeasonNumber'
                }, {
                    name: 'reference',
                    mapping: 'reference'
                }, {
                    name: 'createDate',
                    mapping: 'createDate'
                }, {
                    name: 'ctVersion',
                    mapping: 'ctVersion'
                }, {
                    name: 'patronageNumer',
                    mapping: 'patronageNumer'
                }, {
                    name: 'front',
                    mapping: 'front'
                }, {
                    name: 'back',
                    mapping: 'back'
                }, {
                    name: 'sleeves',
                    mapping: 'sleeves'
                }, {
                    name: 'bottomThrum',
                    mapping: 'bottomThrum'
                }, {
                    name: 'sleevesThrum',
                    mapping: 'sleevesThrum'
                }, {
                    name: 'necklineThrum',
                    mapping: 'necklineThrum'
                }, {
                    name: 'needle',
                    mapping: 'needle'
                }, {
                    name: 'weight',
                    mapping: 'weight'
                }, {
                    name: 'comment',
                    mapping: 'comment'
                }, {
                    name: 'customerID',
                    mapping: 'customerID'
                }, {
                    name: 'photoName',
                    mapping: 'photoName'
                }, {
                    name: 'chartName',
                    mapping: 'chartName'
                }, {
                    name: 'biMeasureSpecificationId',
                    mapping: 'biMeasureSpecificationId'
                }, {
                    name: 'biMeasureSpecificationName',
                    mapping: 'biMeasureSpecificationName'
                }, {
                    name: 'yarnName',
                    mapping: 'yarnName'
                }, {
                    name: 'frontPhotoName',
                    mapping: 'frontPhotoName'
                }, {
                    name: 'backPhotoName',
                    mapping: 'backPhotoName'
                }, {
                    name: 'photoName',
                    mapping: 'photoName'
                }, {
                    name: 'chartName',
                    mapping: 'chartName'
                }, {
                    name: 'ctCollarType',
                    mapping: 'ctCollarType'
                }, {
                    name: 'customerName',
                    mapping: 'customerName'
                }, {
                    name: 'customerDepartment',
                    mapping: 'customerDepartment'
                }]);
                
                var piXmlLoader = new xmlLoader('../../servlet/ProductIdentificationServlet?action=11&id=' + idValue);
                
                var piRecord = piXMLReader.readRecords(piXmlLoader.getXml()).records[0];
                
                var itemTplMarkup = ['<table cellspacing="0" id="the-table" style="width: 100%;"><tbody>',
										 '<tr><td style="background:#eeeeee; width: 15%;">',
										 message.get('message.list.id'), '</td><td>{id}</td>', 
										 '<td style="background:#eeeeee;width: 15%;">', 
										 piMessage.get('ui.productidentification.style'), 
										 '</td><td>{style}</td><td style="background:#eeeeee;">', 
										 piMessage.get('ui.productidentification.seasonnumber'), 
										 '</td><td>{ctSeasonNumber}</td>', '<td style="background:#eeeeee;">', 
										 referenceMessage.get('ui.reference.reference'), 
										 '</td><td>{reference}</td></tr>', 
										 
										 
										 '<tr><td style="background:#eeeeee;">', 
										 message.get('message.edit.productfamily'), 
										 '</td><td>{ctProductFamily}</td><td style="background:#eeeeee;">', 
										 piMessage.get('ui.productidentification.patronagenumer'), 
										 '</td><td>{patronageNumer}</td><td style="background:#eeeeee;">', 
										 piMessage.get('ui.productidentification.chartversion'), 
										 '</td><td>{ctVersion}</td><td style="background:#eeeeee;">', 
										 piMessage.get('ui.productidentification.model'), 
										 '</td><td>{model}</td></tr>',
										 '<tr><td style="background:#eeeeee;">', 
										 referenceMessage.get('ui.reference.weight'), 
										 '</td><td>{weight}</td><td style="background:#eeeeee;">', 
										 message.get('message.edit.collar'), 
										 '</td><td>{ctCollarType}</td><td style="background:#eeeeee;">', 
										 fcMessage.get('ui.francecustomer.name'), 
										 '</td><td>{customerName}</td><td style="background:#eeeeee;">', 
										 fcMessage.get('ui.francecustomer.department'), 
										 '</td><td>{customerDepartment}</td></tr>',
										 
										 '<tr><td colspan="8">',
										 //'<img width="120" src="../../_temp/{frontPhotoName}"/>&nbsp;&nbsp;&nbsp;&nbsp;',
										 //'<img width="120" src="../../_temp/{backPhotoName}"/>&nbsp;&nbsp;&nbsp;&nbsp;',
										 '<img width="120" src="../../_temp/{chartName}"/>&nbsp;&nbsp;&nbsp;&nbsp;',
										 '<img width="120" src="../../_temp/{photoName}"/>',
										 '</td></tr>',
										 '</tbody></table>'];
                var itemTpl = new Ext.Template(itemTplMarkup);
                itemTpl.append('productIdentification', piRecord.data);
                
                
                var piTagXMLReader = new Ext.data.XmlReader({
                    record: 'item'
                }, [{
                        name: 'ctStature',
                        mapping: 'ctStature'
                    },{
                        name: 'isSimilary',
                        mapping: 'isSimilary'
                    },{
                        name: 'isNewfashioned',
                        mapping: 'isNewfashioned'
                    },{
                        name: 'isDifficulty',
                        mapping: 'isDifficulty'
                    },{
                        name: 'unitPrice',
                        mapping: 'unitPrice'
                    },{
                        name: 'dhlNumber',
                        mapping: 'dhlNumber'
                    },{
                        name: 'tagComment',
                        mapping: 'tagComment'
                    }]);
                piTagForm = new Ext.FormPanel({
                    labelAlign: 'left',
                    url: '../../servlet/ProductIdentificationServlet?action=200',
                    frame: true,
                    title: piMessage.get('ui.productidentification.tag'),
                    bodyStyle: 'padding:5px 5px 5px 5px;margin-top: 2px;',
                    width: '100%',
                    labelWidth: 75,
                    reader: piTagXMLReader,
                    items: [{
                        id: 'id',
                        name: 'id',
                        xtype: 'hidden',
                        value: piRecord.data.id
                    }, {
                        layout: 'column',
                        items: [{
                            columnWidth: .5,
                            layout: 'form',
                            items: [ctStatureCombo, isSimilaryCombo,{
								xtype: 'numberfield',
								fieldLabel: piMessage.get('ui.productidentification.unitprice') + '&nbsp;&nbsp;<b>(&nbsp;€&nbsp;)</b>',
								id: 'unitPrice',
								name: 'unitPrice',
								allowBlank: false,
                				blankText: message.get('message.edit.noblank'),
								width: '80%',
								anchor: '90%'
							}]
                        }, {
                            columnWidth: .5,
                            layout: 'form',
                            items: [isNewfashionedCombo, isDifficultyCombo,{
		                        xtype: 'textfield',
		                        fieldLabel: piMessage.get('ui.productidentification.dhl'),
								id: 'dhlNumber',
		                        name: 'dhlNumber',
								width: '80%',
		                        anchor: '90%',
		                        tabIndex: 7
		                    }]
                        }]
                    },{
						xtype: 'textarea',
                        fieldLabel: message.get('message.edit.comment'),
						id: 'tagComment',
                        name: 'tagComment',
						width: '80%',
                        anchor: '90%',
                        tabIndex: 7
					}],
                    
                    buttons: [{
                        text: message.get('message.edit.save'),
                        handler: function(){
							var isSimilary = isSimilaryCombo.getValue();
							var isDifferenty = isDifficultyCombo.getValue();
							var isNewfashinoed = isNewfashionedCombo.getValue();
							var ctStature = ctStatureCombo.getValue();
                            if (piTagForm.getForm().isValid()) {
								document.getElementsByName('isSimilary')[0].value = isSimilaryCombo.getValue();
                                document.getElementsByName('isDifficulty')[0].value = isDifficultyCombo.getValue();
                                document.getElementsByName('isNewfashioned')[0].value = isNewfashionedCombo.getValue();
                                document.getElementsByName('ctStature')[0].value = ctStatureCombo.getValue();
								try{
									piTagForm.getForm().submit({
	                                    method: 'post',
	                                    success: function(form, action){
	                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.successful'));
											isSimilaryCombo.setValue(isSimilary);
											isDifficultyCombo.setValue(isDifferenty);
	                                        isNewfashionedCombo.setValue(isNewfashinoed);
											ctStatureCombo.setValue(ctStature);
	                                    },
	                                    failure: function(form, action){
											isSimilaryCombo.setValue(isSimilary);
											isDifficultyCombo.setValue(isDifferenty);
	                                        isNewfashionedCombo.setValue(isNewfashinoed);
											ctStatureCombo.setValue(ctStature);
	                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.unsuccessful'));
	                                    }
                                	});	
								}catch(e){
									alert(e);
								}
                            }
                        }
                    }, {
                        text: message.get('message.edit.reset'),
                        handler: function(){
                            piTagForm.getForm().reset();
                        }
                    }, {
                        text: message.get('message.edit.cancel'),
                        handler: function(){
                            if (startPage != null) {
                                window.location = 'product_identification_list.html?startPage=' + startPage;
                            }
                            else {
                                window.location = 'product_identification_list.html';
                            }
                        }
                    }]
                });
                
                piTagForm.render('productIdentification');
				
				if (idValue != null) {
					piTagForm.getForm().load({
							url:'../../servlet/ProductIdentificationServlet?action=3&id=' + idValue, 
							waitMsg:Ext.LoadMask.prototype.msg, 
							success: function(form, action){
								
							}
					});
				}
            });
        </script>
    </head>
    <body>
        <div id="productIdentification">
        </div>
        <div id="productIdentificationTagForm">
        </div>
    </body>
</html>
